package com.example.service;


import com.example.entity.User;
import com.example.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserServiceImpl implements UserService{



    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> selectUserList() {
        List<User> list = userMapper.selectUserList();
        return list;
    }


//    @Transactional
    @Override
    public int insertUser(User user) {
        int i = userMapper.insertUser(user);

        User u = new User();
        u.setId(1);
        u.setName("英语");
        updateUser(u);
        int a = 1/0;
        return i;
    }


    @Transactional(propagation= Propagation.REQUIRED)
    @Override
    public int updateUser(User user) {
        int i = userMapper.updateUser(user);

        return i;
    }
}
